/* 
 * Copyright (c) 2012 JSquirrelEngine
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in 
 * the Software without restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
 * Software, and to permit persons to whom the Software is furnished to do so, subject
 * to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 */

package org.jsquirrel.map.impl;

import org.jsquirrel.geometry.Polygon;
import org.jsquirrel.map.Space2DNode;


/**
 * Implementation of {@link Space2DNode} for {@link GridSpace2D}
 * 
 * @author Juan David Adarve Bermudez
 *
 * @param <K> node key
 * @param <O> node
 */
public class GridSpace2DNode<K extends Comparable<K>, O> extends Space2DNode<K, O> {
	
	//*********************************************************************************************
	// INSTANCE ATTRIBUTES
	//*********************************************************************************************
	
	/**
	 * flag to indicate whether the node is at limbo.
	 */
	private boolean atLimbo;

	
	//*********************************************************************************************
	// CONSTRUCTOR
	//*********************************************************************************************
	
	public GridSpace2DNode(Polygon p, K ID) {
		super(p, ID);
		atLimbo = false;
	}

	

	
	//*********************************************************************************************
	// PUBLIC METHODS
	//*********************************************************************************************
	
	@Override
	public int compareTo(Space2DNode<K, O> o) {
		
		return this.getKey().compareTo(o.getKey());
	}
	
	/**
	 * Set whether or not the node is at limbo area
	 * 
	 * @param atLimbo
	 */
	public void setLimboFlag(boolean atLimbo) {
		this.atLimbo = atLimbo;
	}
	
	/**
	 * Get the value of the limbo flag
	 * 
	 * @return
	 */
	public boolean atLimbo() {
		return atLimbo;
	}
	
	@Override
	public String toString() {
		
		return "{key=" + this.getKey().toString() + ", limbo=" + atLimbo + ", OI=" + this.objectInterval + ", TI=" + this.triggerInterval + ", polygon= " + this.shape + "}";
	}
}
